package com.example.config;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
import io.swagger.v3.oas.annotations.info.Contact;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.info.License;
import io.swagger.v3.oas.annotations.security.SecurityScheme;
import io.swagger.v3.oas.annotations.servers.Server;
import io.swagger.v3.oas.models.OpenAPI;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * Knife4J 配置类（适用于Spring Boot 3）
 */
@Configuration
@OpenAPIDefinition(
        info = @Info(
                title = "论坛系统API文档", 
                version = "1.0", 
                description = "基于Spring Boot和Knife4j的论坛系统API文档",
                contact = @Contact(name = "开发者", email = "example@email.com", url = "https://github.com"),
                license = @License(name = "Apache 2.0", url = "http://localhost:58080/")
        ),
        servers = { 
            @Server(url = "http://localhost:58080", description = "本地开发环境")
            /*@Server(url = "http://your-prod-url.com", description = "生产环境") */
        }
)
@SecurityScheme(
        name = "bearerAuth",
        type = SecuritySchemeType.HTTP,
        scheme = "bearer",
        bearerFormat = "JWT"
)
public class Knife4jConfig {

        /**
         * 配置OpenAPI基本信息
         * @return OpenAPI
         */
        @Bean
        public OpenAPI customOpenAPI() {
                return new OpenAPI()
                        .info(new io.swagger.v3.oas.models.info.Info()
                                .title("论坛系统API文档")
                                .version("1.0")
                                .description("基于Spring Boot和Knife4j的论坛系统API文档"));
        }

}
